/**
 * Created by CHENED2 on 8/13/2015.
 */
var request = require('request');
var cheerio = require('cheerio');
var async = require('async');
var mkdirp = require('mkdirp');
var fs = require('fs');

Crawler.prototype.crawl = function (){


};


Crawler.prototype.request = function (url, callback) {
    var me = this;
    request(url,function(err, res, body){
        var $ = null;
        if(!err && res.statusCode == 200){
            $ = cheerio.load(body);
        }else{
            console.log('request failed, url:' + url);
        }
        callback(!!$,$);
    })
};


Crawler.prototype.text = function (urls) {
    var me = this;
    async.whilst(function(){
        return i < urls.length;
    },function(callback){
        var url = url[i];
        //me.request(url,)
    },function(err){
        if(err){
            console.log('err: '+ err);
        }else{
            console.log('text successfully.');
        }
    })
};


